<template>
  <div class="login" :style="{height:heights+'px'}">
    <div class="form">
      <div class="form-left">
        <img class="img" src="../assets/images/img.png" />
      </div>
      <div class="form-right">
        <el-form
          :model="ruleForm"
          :rules="rules"
          ref="ruleForm"
          label-width="100px"
          class="demo-ruleForm"
        >
          <el-form-item label="账号" prop="pass">
            <el-input type="password" v-model="ruleForm.pass" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="密码" prop="pass">
            <el-input type="password" v-model="ruleForm.pass" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="确认密码" prop="checkPass">
            <el-input type="password" v-model="ruleForm.checkPass" autocomplete="off"></el-input>
          </el-form-item>
          <!-- <el-form-item label="验证码">
            <el-input type="password" v-model="ruleForm.yanPass" autocomplete="off"></el-input>
          </el-form-item>-->
          <el-form-item>
            <el-button type="primary" class style="width:300px">马上登录</el-button>
          </el-form-item>
          <!-- <el-form-item>
            <span>忘记密码</span>
            <span>注册</span>
          </el-form-item>-->
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    var validatePass = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入密码"));
      } else {
        if (this.ruleForm.checkPass !== "") {
          this.$refs.ruleForm.validateField("checkPass");
        }
        callback();
      }
    };
    var validatePass2 = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请再次输入密码"));
      } else if (value !== this.ruleForm.pass) {
        callback(new Error("两次输入密码不一致!"));
      } else {
        callback();
      }
    };
    return {
      heights: "",
      ruleForm: {
        pass: "",
        checkPass: "",
        yanPass: ""
      },
      rules: {
        pass: [{ validator: validatePass, trigger: "blur" }],
        checkPass: [{ validator: validatePass2, trigger: "blur" }]
      }
    };
  },
  mounted() {
    this.heights = document.documentElement.clientHeight;
  }
};
</script>

<style lang="scss" scoped>
.login {
  // background: url("../assets/images/background.png") no-repeat center;
  // background-color: rgba(82, 131, 251, 0.8);
  background-color: rgba(235, 238, 245, 0.8);
  background-size: 100% 100%;
  text-align: center;
  position: relative;
  .form {
    width: 900px;
    height: 500px;
    background: url("../assets/images/frameBg.png") no-repeat center;
    background-size: 100% 100%;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    margin: auto;
    -moz-box-shadow: 2px 3px 3px 3px rgba(30, 30, 30, 0.26);
    -webkit-box-shadow: 2px 3px 3px 3px rgba(30, 30, 30, 0.26);
    box-shadow: 2px 3px 3px 3px rgba(30, 30, 30, 0.26);
    .form-left {
      float: left;
      width: 420px;
      height: 500px;
      .img {
        padding-top: 80px;
        width: 260px;
      }
    }
    .form-right {
      float: left;
      width: 400px;
      height: 500px;

      .demo-ruleForm {
        padding-top: 110px;
      }
    }
  }
}
</style>

